<template>
  <div id="box">
    <button @click="show_div">点击弹出</button>
    <Teleport to="body">
      <div class="mask" v-if="show">
        <div class="popup">
          <p>确定删除吗？</p >
          <div>
            <el-button @click="fn1" type="primary">确定</el-button>
            <el-button @click="fn2" type="info">取消</el-button>
          </div>
        </div>
      </div>
    </Teleport>
  </div>
</template>

<script>
import { ref } from "vue";

export default {
  setup() {
    let aa = ref("aa");
    let show = ref(false);
    // 弹窗
    function show_div() {
      show.value = true;
    }
    // 确定
    function fn1() {
      console.log("删除了");
      show.value = false;
    }
    // 取消
    function fn2() {
      show.value = false;
    }
    return { aa, show_div, show, fn1, fn2 };
  },
};
</script>
<style lang="less">
#box {
}
.mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(116, 116, 116, 0.445);
}
.popup {
  width: 300px;
  height: 150px;
  background-color: aqua;
  text-align: center;
  padding-top: 50px;
  position: absolute;
  top: 30%;
  left: calc((100% - 300px) / 2);
  z-index: 1;
}
</style>